#!/bin/bash
#判断输入的参数个数是否小于1
if [ $# -lt 1 ]
then
        #输出 没有输入参数
    echo "No Args Input..."
    exit ;
fi
#根据输入的参数判断
case $1 in
"start")
        echo " =================== 启动 hadoop集群 ==================="

        echo " --------------- 启动 hdfs ---------------"
        ssh hadoop101 "/opt/bdp/hadoop-3.1.3/sbin/start-dfs.sh"
        echo " --------------- 启动 yarn ---------------"
        ssh hadoop102 "/opt/bdp/hadoop-3.1.3/sbin/start-yarn.sh"
        echo " --------------- 启动 historyserver ---------------"
        ssh hadoop101 "/opt/bdp/hadoop-3.1.3/bin/mapred --daemon start historyserver"
;;
"stop")
        echo " =================== 关闭 hadoop集群 ==================="

        echo " --------------- 关闭 historyserver ---------------"
        ssh hadoop101 "/opt/bdp/hadoop-3.1.3/bin/mapred --daemon stop historyserver"
        echo " --------------- 关闭 yarn ---------------"
        ssh hadoop102 "/opt/bdp/hadoop-3.1.3/sbin/stop-yarn.sh"
        echo " --------------- 关闭 hdfs ---------------"
        ssh hadoop101 "/opt/bdp/hadoop-3.1.3/sbin/stop-dfs.sh"
;;
#排除上面两种start和stop的情况的所有情况
*)
        #输出 参数输入错误
    echo "Input Args Error..."
;;
esac